package weiyao.xinxidasai.config.Redis;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
import weiyao.xinxidasai.mapper.VersionMapper;

import javax.annotation.PostConstruct;
import java.util.List;

@Component("versionBloomFilter")
public class VersionBloomFilter extends BloomFilter {
      @Autowired
    private VersionMapper versionMapper;
    @PostConstruct
    public void init() {
        deletedKeys.clear();
        List<String> validVersions = versionMapper.getAllValidVersionNos();
        validVersions.forEach(this::add);
        System.out.println("版本号白名单初始化完成");
        if (validVersions.isEmpty()) {
            throw new IllegalStateException("有效版本号列表为空！");
        }
    }
}
